<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>搭建GitLab服务器 及 GitLab-CI服务 | MoneyLee’s Blog</title><meta name="author" content="李财"><meta name="copyright" content="李财"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="GitLab Server 的搭建参考 https:&#x2F;&#x2F;about.gitlab.com&#x2F;installation 1. 准备工作以Centos7为例，准备一台至少内存为4G的机器。 2. 安装依赖软件12345678sudo yum install -y git vim gcc glibc-static telnetsudo yum install -y curl policycoreutils">
<meta property="og:type" content="article">
<meta property="og:title" content="搭建GitLab服务器 及 GitLab-CI服务">
<meta property="og:url" content="https://moneylee.gitee.io/blog/2019/06/10/%E6%90%AD%E5%BB%BAGitLab%E6%9C%8D%E5%8A%A1%E5%99%A8/index.html">
<meta property="og:site_name" content="MoneyLee’s Blog">
<meta property="og:description" content="GitLab Server 的搭建参考 https:&#x2F;&#x2F;about.gitlab.com&#x2F;installation 1. 准备工作以Centos7为例，准备一台至少内存为4G的机器。 2. 安装依赖软件12345678sudo yum install -y git vim gcc glibc-static telnetsudo yum install -y curl policycoreutils">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg">
<meta property="article:published_time" content="2019-06-10T12:12:02.000Z">
<meta property="article:modified_time" content="2020-08-20T08:35:07.000Z">
<meta property="article:author" content="李财">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://moneylee.gitee.io/blog/2019/06/10/%E6%90%AD%E5%BB%BAGitLab%E6%9C%8D%E5%8A%A1%E5%99%A8/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: undefined,
  localSearch: undefined,
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: '搭建GitLab服务器 及 GitLab-CI服务',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2020-08-20 16:35:07'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/blog/atom.xml" title="MoneyLee’s Blog" type="application/atom+xml">
</head><body><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2019/11/10/SYvXMgCFuTNOVeZ.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">47</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fa fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/bbs/"><i class="fa-fw fa fa-coffee"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 影音</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/music"><i class="fa-fw /music/"></i><span> 0</span></a></li><li><a class="site-page child" href="/blog/movies"><i class="fa-fw /movies/"></i><span> 1</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">MoneyLee’s Blog</a></span><div id="menus"><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fa fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fa fa-archive"></i><span> 时间轴</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fa fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fa fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/bbs/"><i class="fa-fw fa fa-coffee"></i><span> 留言板</span></a></div><div class="menus_item"><a class="site-page" href="/blog/link/"><i class="fa-fw fa fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fa fa-heart"></i><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fa fa-list"></i><span> 影音</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/blog/music"><i class="fa-fw /music/"></i><span> 0</span></a></li><li><a class="site-page child" href="/blog/movies"><i class="fa-fw /movies/"></i><span> 1</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">搭建GitLab服务器 及 GitLab-CI服务</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2019-06-10T12:12:02.000Z" title="发表于 2019-06-10 20:12:02">2019-06-10</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2020-08-20T08:35:07.000Z" title="更新于 2020-08-20 16:35:07">2020-08-20</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/%E8%BF%90%E7%BB%B4/">运维</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="搭建GitLab服务器 及 GitLab-CI服务"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h1 id="GitLab-Server-的搭建"><a href="#GitLab-Server-的搭建" class="headerlink" title="GitLab Server 的搭建"></a>GitLab Server 的搭建</h1><p>参考 <a target="_blank" rel="noopener" href="https://about.gitlab.com/installation">https://about.gitlab.com/installation</a></p>
<h2 id="1-准备工作"><a href="#1-准备工作" class="headerlink" title="1. 准备工作"></a>1. 准备工作</h2><p>以Centos7为例，准备一台至少内存为4G的机器。</p>
<h2 id="2-安装依赖软件"><a href="#2-安装依赖软件" class="headerlink" title="2. 安装依赖软件"></a>2. 安装依赖软件</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">sudo yum install -y git vim gcc glibc-static telnet</span><br><span class="line">sudo yum install -y curl policycoreutils-python openssh-server</span><br><span class="line">sudo systemctl enable sshd</span><br><span class="line">sudo systemctl start sshd</span><br><span class="line"></span><br><span class="line">sudo yum install postfix</span><br><span class="line">sudo systemctl enable postfix</span><br><span class="line">sudo systemctl start postfix</span><br></pre></td></tr></table></figure>


<h2 id="3-设置gitlab安装源"><a href="#3-设置gitlab安装源" class="headerlink" title="3. 设置gitlab安装源"></a>3. 设置gitlab安装源</h2><p>如果在国内的话，可以尝试使用清华大学的源。</p>
<p>新建 /etc/yum.repos.d/gitlab-ce.repo，内容为</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">[gitlab-ce]</span><br><span class="line">name=Gitlab CE Repository</span><br><span class="line">baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/</span><br><span class="line">gpgcheck=0</span><br><span class="line">enabled=1</span><br></pre></td></tr></table></figure>

<p>如果在国外的话，可以使用</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash</span><br></pre></td></tr></table></figure>

<h2 id="4-安装GitLab"><a href="#4-安装GitLab" class="headerlink" title="4. 安装GitLab"></a>4. 安装GitLab</h2><p>关于域名，如果要是设置域名，则如下，这个域名可以是真实购买的域名，如果您要把gitlab安装到公网比如阿里云上的话。</p>
<p>如果只是想本地测试，则可以像下面一样，设置一个example的域名，然后记得在本地你的笔记本设置host，如果是MAC就在 /etc/hosts里添加 一行 <code>192.168.211.10 gitlab.example.com</code>  </p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo EXTERNAL_URL=&quot;http://gitlab.moneylee.cn&quot; yum install -y gitlab-ce</span><br></pre></td></tr></table></figure>

<p>如果不想设置域名，或者想将来再考虑，可以直接</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo yum install -y gitlab-ce</span><br></pre></td></tr></table></figure>

<p>安装完成以后，运行下面的命令进行配置</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">sudo gitlab-ctl reconfigure</span><br></pre></td></tr></table></figure>

<p>报错:</p>
<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlly1ghx4cefhl6j31oi082tad.jpg" alt="截屏2020-08-20 上午11.28.34"></p>
<p>解决:</p>
<p>删除/etc/gitlab/gitlab-secrets.json文件，再次运行<code>gitlab-ctl reconfigure</code></p>
<h2 id="5-登陆和修改密码"><a href="#5-登陆和修改密码" class="headerlink" title="5. 登陆和修改密码"></a>5. 登陆和修改密码</h2><p>打开<a target="_blank" rel="noopener" href="http://gitlab.example.com/">http://gitlab.example.com/</a> 修改root用户密码，然后使用root和新密码登陆。</p>
<p><img src="https://tva1.sinaimg.cn/large/007S8ZIlly1ghx37hlym6j319x0u0k12.jpg" alt="gitlab"></p>
<p><strong>资金有限 我的云服务器是2G的 安装特别卡 这个很占内存 还出了很多问题 解决难度很大 采用Docker安装试试</strong></p>
<p>拉取镜像:</p>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># gitlab-ce为稳定版本，后面不填写版本则默认pull最新latest版本</span></span><br><span class="line"><span class="variable">$ </span>docker pull gitlab/gitlab-ce</span><br></pre></td></tr></table></figure>

<p>运行镜像:</p>
<figure class="highlight csharp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">$ docker run -d  -p <span class="number">443</span>:<span class="number">443</span> -p <span class="number">80</span>:<span class="number">80</span> -p <span class="number">222</span>:<span class="number">22</span> --name gitlab --restart always -v /home/gitlab/config:/etc/gitlab -v /home/gitlab/logs:/<span class="keyword">var</span>/log/gitlab -v /home/gitlab/data:/<span class="keyword">var</span>/opt/gitlab gitlab/gitlab-ce</span><br><span class="line"><span class="meta"># -d：后台运行</span></span><br><span class="line"><span class="meta"># -p：将容器内部端口向外映射</span></span><br><span class="line"><span class="meta"># --name：命名容器名称</span></span><br><span class="line"><span class="meta"># -v：将容器内数据文件夹或者日志、配置等文件夹挂载到宿主机指定目录</span></span><br></pre></td></tr></table></figure>

<p>配置</p>
<p>按上面的方式，gitlab容器运行没问题，但在gitlab上创建项目的时候，生成项目的URL访问地址是按容器的hostname来生成的，也就是容器的id。作为gitlab服务器，我们需要一个固定的URL访问地址，于是需要配置gitlab.rb（宿主机路径：/home/gitlab/config/gitlab.rb）。</p>
<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># gitlab.rb文件内容默认全是注释</span></span><br><span class="line"><span class="variable">$ </span>vim /home/gitlab/config/gitlab.rb</span><br></pre></td></tr></table></figure>

<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 配置http协议所使用的访问地址,不加端口号默认为80</span></span><br><span class="line">external_url <span class="string">&#x27;http://192.168.199.231&#x27;</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 配置ssh协议所使用的访问地址和端口</span></span><br><span class="line">gitlab_rails[<span class="string">&#x27;gitlab_ssh_host&#x27;</span>] = <span class="string">&#x27;192.168.199.231&#x27;</span></span><br><span class="line">gitlab_rails[<span class="string">&#x27;gitlab_shell_ssh_port&#x27;</span>] = <span class="number">222</span> <span class="comment"># 此端口是run时22端口映射的222端口</span></span><br><span class="line"><span class="symbol">:wq</span> <span class="comment">#保存配置文件并退出</span></span><br></pre></td></tr></table></figure>

<figure class="highlight ruby"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 重启gitlab容器</span></span><br><span class="line"><span class="variable">$ </span>docker restart gitlab</span><br></pre></td></tr></table></figure>

<p>此时项目的仓库地址就变了。如果ssh端口地址不是默认的22，就会加上ssh:// 协议头<br> 打开浏览器输入ip地址(因为我的gitlab端口为80，所以浏览器url不用输入端口号，如果端口号不是80，则打开为：ip:端口号)</p>
<p>创建项目</p>
<p>第一次进入要输入新的root用户密码，设置好之后确定就行</p>
<h1 id="GitLab-CI-服务器的搭建"><a href="#GitLab-CI-服务器的搭建" class="headerlink" title="GitLab CI 服务器的搭建"></a>GitLab CI 服务器的搭建</h1><p>GitLab CI服务器最好是单独与gitlab服务器的一台Linux机器。</p>
<h2 id="1-安装Docker"><a href="#1-安装Docker" class="headerlink" title="1. 安装Docker"></a>1. 安装Docker</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">curl -sSL https://get.docker.com/ | sh</span><br></pre></td></tr></table></figure>


<h2 id="2-安装gitlab-ci-runner"><a href="#2-安装gitlab-ci-runner" class="headerlink" title="2. 安装gitlab ci runner"></a>2. 安装gitlab ci runner</h2><figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-ci-multi-runner/script.rpm.sh | sudo bash</span><br><span class="line">sudo yum install gitlab-ci-multi-runner -y</span><br></pre></td></tr></table></figure>

<p>查看是否运行正常</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">[vagrant@gitlab-ci ~]$ sudo gitlab-ci-multi-runner status</span><br><span class="line">gitlab-runner: Service is running!</span><br><span class="line">[vagrant@gitlab-ci ~]$</span><br></pre></td></tr></table></figure>

<h2 id="3-设置Docker权限"><a href="#3-设置Docker权限" class="headerlink" title="3. 设置Docker权限"></a>3. 设置Docker权限</h2><p>为了能让gitlab-runner能正确的执行docker命令，需要把gitlab-runner用户添加到docker group里, 然后重启docker和gitlab ci runner</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">[vagrant@gitlab-ci ~]$ sudo usermod -aG docker gitlab-runner</span><br><span class="line">[vagrant@gitlab-ci ~]$ sudo service docker restart</span><br><span class="line">Redirecting to /bin/systemctl restart docker.service</span><br><span class="line">[vagrant@gitlab-ci ~]$ sudo gitlab-ci-multi-runner restart</span><br></pre></td></tr></table></figure>

</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">李财</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://moneylee.gitee.io/blog/2019/06/10/%E6%90%AD%E5%BB%BAGitLab%E6%9C%8D%E5%8A%A1%E5%99%A8/">https://moneylee.gitee.io/blog/2019/06/10/%E6%90%AD%E5%BB%BAGitLab%E6%9C%8D%E5%8A%A1%E5%99%A8/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://moneylee.gitee.io/blog" target="_blank">MoneyLee’s Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/2019/08/10/U%E7%9B%98%E5%AE%89%E8%A3%85CentOS7.4/"><img class="prev-cover" src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">U盘安装CentOS 7.4</div></div></a></div><div class="next-post pull-right"><a href="/blog/2019/06/10/Windows%20Server%202012%20Nginx/"><img class="next-cover" src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl6v5kt7j31g60squ0y.jpg" onerror="onerror=null;src='/blog/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">Windows Server 2012 安装 Nginx</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src="https://i.loli.net/2019/11/10/SYvXMgCFuTNOVeZ.png" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">李财</div><div class="author-info__description">嗨，我是李财 (MoneyLee)， 一名来自中国的 iOS开发者。</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">47</div></a></div><div class="card-info-data-item is-center"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">9</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/xxxxxx"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/licai28" target="_blank" title=""><i class="fa fa-github"></i></a><a class="social-icon" href="mailto:licai_1024@hotmail.com" target="_blank" title=""><i class="fa fa-envelope"></i></a><a class="social-icon" href="/blog/img/mywechat.jpg" target="_blank" title=""><i class="fa fa-weixin"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-1"><a class="toc-link" href="#GitLab-Server-%E7%9A%84%E6%90%AD%E5%BB%BA"><span class="toc-number">1.</span> <span class="toc-text">GitLab Server 的搭建</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%87%86%E5%A4%87%E5%B7%A5%E4%BD%9C"><span class="toc-number">1.1.</span> <span class="toc-text">1. 准备工作</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85%E4%BE%9D%E8%B5%96%E8%BD%AF%E4%BB%B6"><span class="toc-number">1.2.</span> <span class="toc-text">2. 安装依赖软件</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E8%AE%BE%E7%BD%AEgitlab%E5%AE%89%E8%A3%85%E6%BA%90"><span class="toc-number">1.3.</span> <span class="toc-text">3. 设置gitlab安装源</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E5%AE%89%E8%A3%85GitLab"><span class="toc-number">1.4.</span> <span class="toc-text">4. 安装GitLab</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#5-%E7%99%BB%E9%99%86%E5%92%8C%E4%BF%AE%E6%94%B9%E5%AF%86%E7%A0%81"><span class="toc-number">1.5.</span> <span class="toc-text">5. 登陆和修改密码</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link" href="#GitLab-CI-%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E6%90%AD%E5%BB%BA"><span class="toc-number">2.</span> <span class="toc-text">GitLab CI 服务器的搭建</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%AE%89%E8%A3%85Docker"><span class="toc-number">2.1.</span> <span class="toc-text">1. 安装Docker</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E5%AE%89%E8%A3%85gitlab-ci-runner"><span class="toc-number">2.2.</span> <span class="toc-text">2. 安装gitlab ci runner</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E8%AE%BE%E7%BD%AEDocker%E6%9D%83%E9%99%90"><span class="toc-number">2.3.</span> <span class="toc-text">3. 设置Docker权限</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2021/09/14/Flutter%20%E5%90%AF%E5%8A%A8%E9%A1%B5%E9%85%8D%E7%BD%AE/" title="无题"><img src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/img/default.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="无题"/></a><div class="content"><a class="title" href="/blog/2021/09/14/Flutter%20%E5%90%AF%E5%8A%A8%E9%A1%B5%E9%85%8D%E7%BD%AE/" title="无题">无题</a><time datetime="2021-09-14T03:05:25.000Z" title="发表于 2021-09-14 11:05:25">2021-09-14</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2020/08/21/iOS%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" title="iOS机器学习"><img src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl0019wlj31ej0u0x6q.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="iOS机器学习"/></a><div class="content"><a class="title" href="/blog/2020/08/21/iOS%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/" title="iOS机器学习">iOS机器学习</a><time datetime="2020-08-21T02:04:10.000Z" title="发表于 2020-08-21 10:04:10">2020-08-21</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2020/08/20/Docker%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86/" title="Docker 基础知识整理"><img src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl4zhjzuj30qy0e0gyz.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Docker 基础知识整理"/></a><div class="content"><a class="title" href="/blog/2020/08/20/Docker%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86%E6%95%B4%E7%90%86/" title="Docker 基础知识整理">Docker 基础知识整理</a><time datetime="2020-08-20T12:12:02.000Z" title="发表于 2020-08-20 20:12:02">2020-08-20</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2020/08/19/Flutter/" title="Flutter"><img src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl0019wlj31ej0u0x6q.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="Flutter"/></a><div class="content"><a class="title" href="/blog/2020/08/19/Flutter/" title="Flutter">Flutter</a><time datetime="2020-08-19T02:04:03.000Z" title="发表于 2020-08-19 10:04:03">2020-08-19</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2020/08/19/iOS%20AR%E5%92%8CARKit4/" title="iOS AR和ARKit4"><img src="https://tva1.sinaimg.cn/large/006y8mN6ly1g8vl0019wlj31ej0u0x6q.jpg" onerror="this.onerror=null;this.src='/blog/img/404.jpg'" alt="iOS AR和ARKit4"/></a><div class="content"><a class="title" href="/blog/2020/08/19/iOS%20AR%E5%92%8CARKit4/" title="iOS AR和ARKit4">iOS AR和ARKit4</a><time datetime="2020-08-19T02:04:03.000Z" title="发表于 2020-08-19 10:04:03">2020-08-19</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By 李财</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><div class="js-pjax"></div><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>